<%@ page import="java.util.List" %>
<%@ page import="user.User" %>
<%@ page import="com.example.demo_text.UserDAO" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理学生信息</title>
    <style>
        /* 全局样式 */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft Yahei', sans-serif;
            background: linear-gradient(135deg, #e0f7fa, #f3e5f5);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px 20px;
            color: #333;
        }

        .card {
            background: white;
            width: 100%;
            max-width: 600px;
            padding: 30px 25px;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
        }

        h2 {
            text-align: center;
            margin-bottom: 24px;
            font-weight: 600;
            color: #374151;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        th {
            background-color: #f9fafb;
            color: #4b5563;
        }

        .btn {
            display: inline-block;
            padding: 6px 12px;
            background-color: #d1ecf1;
            color: #15576b;
            border-radius: 6px;
            text-decoration: none;
            font-size: 14px;
            transition: background 0.3s, color 0.3s;
        }

        .btn:hover {
            background-color: #aee2eb;
            color: #0f3d4d;
        }

        .back-link {
            display: block;
            text-align: center;
            margin-top: 20px;
            color: #3498db;
            text-decoration: underline;
            font-size: 14px;
        }

        .back-link:hover {
            color: #2980b9;
        }
    </style>
</head>
<body>

<%
    // 获取所有学生
    List<User> students = UserDAO.getAllStudents();
%>

<div class="card">
    <h2>学生信息列表</h2>
    <table>
        <thead>
        <tr>
            <th>用户名</th>
            <th>邮箱</th>
            <th>年龄</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <% for (User student : students) { %>
        <tr>
            <td><%= student.getUsername() %></td>
            <td><%= student.getEmail() %></td>
            <td><%= student.getAge() %></td>
            <td>
                <a href="manageStudent.jsp?id=<%= student.getId() %>" class="btn">编辑</a>
            </td>
        </tr>
        <% } %>
        </tbody>
    </table>
    <a href="AdmitHome.jsp" class="back-link">返回管理员主页</a>
</div>

</body>
</html>
